//
//  ProductTableViewCell.m
//  littleLight's Project-A
//
//  Created by dllo on 16/5/17.
//  Copyright © 2016年 light. All rights reserved.
//

#import "ProductTableViewCell.h"
#import <UIImageView+WebCache.h>

@interface ProductTableViewCell ()
@property (nonatomic, strong) UIView *backView;
@end

@implementation ProductTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}


- (void)createView
{
    
    self.cover = [[UIImageView alloc] init];
    self.cover.layer.masksToBounds = YES;
    self.cover.layer.cornerRadius = 5;
    self.cover.alpha = 0.8;
    [self.contentView addSubview:self.cover];
    
    self.backView  = [[UIView alloc] init];
    self.backView.backgroundColor = [UIColor blackColor];
    self.backView.layer.cornerRadius = 5;
    self.backView.alpha = 0.3;
    [self.contentView addSubview:self.backView];
    
    self.title = [[UILabel alloc] init];
    self.title.textAlignment = NSTextAlignmentCenter;
    self.title.textColor = [UIColor whiteColor];
    self.title.font = [UIFont systemFontOfSize:50];
    self.title.font = [UIFont boldSystemFontOfSize:25];
    self.title.alpha = 1;
    [self.contentView addSubview:self.title];
    
    self.sub_title = [[UILabel alloc] init];
    self.sub_title.textColor = [UIColor whiteColor];
    self.sub_title.textAlignment = NSTextAlignmentCenter;
    self.sub_title.font = [UIFont boldSystemFontOfSize:19];
    [self.contentView addSubview:self.sub_title];
    
    

}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.cover.frame = CGRectMake(10, 5, self.contentView.frame.size.width - 20, self.contentView.frame.size.height - 10);
    self.backView.frame = CGRectMake(10, 5, self.contentView.frame.size.width - 20, self.contentView.frame.size.height - 10);
    self.title.frame = CGRectMake(40, self.contentView.frame.size.height / 2  - 60, 300, 100);
    self.sub_title.frame = CGRectMake(40, self.contentView.frame.size.height / 2  + 10, 300, 50);
}

- (void)setModel:(ElementsData *)model
{
    _model = model;
    
    [self.cover sd_setImageWithURL:[NSURL URLWithString:_model.cover]];
    self.sub_title.text = [NSString stringWithFormat:@"「 %@ 」",_model.sub_title];
    self.title.text = _model.title;
    
    
    
    
    
}


@end
